package com.iseastar.guojiang.register;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.iseastar.BaseActivity2;
import com.iseastar.guojiang.app.AppCache;
import com.iseastar.guojiang.model.UserBean;
import com.shouhuobao.station.R;

import droid.frame.utils.GlideUtil;
import droid.frame.utils.lang.StringReplaceUtil;

/**
 * Created by joker on 2018/5/4.
 * 火箭侠资料详情
 */
public class CourierPerfectInfoDetailActivity extends BaseActivity2 {

    private UserBean userBean = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        userBean = (UserBean) getIntent().getSerializableExtra("item");
        if (userBean == null) {
            userBean = AppCache.getUser();
        }
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void findViewById() {
        setContentView(R.layout.activity_register_perfectinfo_detail);
        super.findViewById();
        getAppTitle().setCommonTitle("资料详情");
        UserBean.CourierAudit courierAudit = userBean.getCourierAudit();
        TextView mAuditStatusContentTV = (TextView) findViewById(R.id.audit_status_content_tv);
        if (userBean != null && courierAudit != null) {
            //审核状态
            if (courierAudit.getAuditStatus() == 1) {
                ((TextView) findViewById(R.id.audit_status_tv)).setText("申请状态：审核中");
                mAuditStatusContentTV.setVisibility(View.VISIBLE);
            } else if (courierAudit.getAuditStatus() == 2) {
                ((TextView) findViewById(R.id.audit_status_tv)).setText("申请状态：审核成功");
                mAuditStatusContentTV.setVisibility(View.GONE);
            } else {
                ((TextView) findViewById(R.id.audit_status_tv)).setText("申请状态：审核失败");
                mAuditStatusContentTV.setVisibility(View.GONE);
            }
            //正面身份证照片
            if (isNotEmpty(courierAudit.getIdCardFaceImg())) {
                GlideUtil.loadImage(getContext(), courierAudit.getIdCardFaceImg(), 0, ((ImageView) findViewById(R.id.idcard_face_iv)));
            }
            //手持身份证照片
            if (isNotEmpty(courierAudit.getIdCardBackImg())) {
                GlideUtil.loadImage(getContext(), courierAudit.getIdCardBackImg(), 0, ((ImageView) findViewById(R.id.courier_in_hand_iv)));
            }
            //火箭侠名字
            if (isNotEmpty(courierAudit.getName())) {
                String name = courierAudit.getName();
                String screctName = "";
                if (name.length() <= 2) {
                    screctName = name.replace(name.substring(1), "*");
                } else {
                    StringBuilder replaceStr = new StringBuilder();
                    for (int i = 1; i <= name.substring(1).length(); i++) {
                        replaceStr.append("*");
                    }
                    screctName = name.replace(name.substring(1), replaceStr.toString());
                }
                ((TextView) findViewById(R.id.courier_name_tv)).setText(screctName);
            }
            //火箭侠性别
            if (courierAudit.getSex() == 2) {
                ((TextView) findViewById(R.id.courier_sex_tv)).setText("女");
            } else {
                ((TextView) findViewById(R.id.courier_sex_tv)).setText("男");
            }
            //民族
            ((TextView) findViewById(R.id.courier_nation_tv)).setText(courierAudit.getNation());
            //身份证号
            ((TextView) findViewById(R.id.courier_cardnumber_tv)).setText(StringReplaceUtil.idCardReplaceWithStar(courierAudit.getIdCardNo(), 6, 4, "*"));
            //地址
            ((TextView) findViewById(R.id.courier_address_tv)).setText(courierAudit.getAddresss());
            //手机号
            ((TextView) findViewById(R.id.courier_phone_tv)).setText(StringReplaceUtil.idCardReplaceWithStar(courierAudit.getPhone(), 3, 4, "*"));
        }
    }
}
